﻿using Report_IService.Web;
using Report_Service.Web;
using Report_Unity.Basic;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Web;
using System.Web.Http;

namespace ReportWebApi.Controllers.Api.WeiXin
{
    [RoutePrefix("api/Hospital")]
    public class HospitalController : BaseApiController
    {
        private IT_HospitalService T_HospitalService = new T_HospitalService();

        [HttpPost,Route("AddHospital")]
        public ResultInfo AddHospital()
        {
            var req = HttpContext.Current.Request;
            string name = req.Form["name"];
            string desc = req.Form["desc"];
            string userid = req.Form["userid"];

            ResultInfo res = T_HospitalService.AddHospital(name, desc, userid);
            return res;
        }

        [HttpPost, Route("EditHospital")]
        public ResultInfo EditHospital()
        {
            var req = HttpContext.Current.Request;
            string hid = req.Form["hid"];
            string name = req.Form["name"];
            string desc = req.Form["desc"];
            string userid = req.Form["userid"];

            ResultInfo res = T_HospitalService.EditHospital(hid,name, desc, userid);
            return res;
        }

        [HttpPost, Route("DelHospital")]
        public ResultInfo DelHospital()
        {
            var req = HttpContext.Current.Request;
            string hid = req.Form["hid"];

            ResultInfo res = T_HospitalService.DelHospital(hid);
            return res;
        }

        [HttpGet, Route("GetListHospital")]
        public ResultInfo GetListHospital()
        {
            ResultInfo res = T_HospitalService.GetListHospital();
            return res;
        }

        [HttpGet, Route("GetHospital")]
        public ResultInfo GetHospital(string hid)
        {
            ResultInfo res = T_HospitalService.GetHospital(hid);
            return res;
        }

        [HttpGet, Route("GetLoginTicket")]
        public ResultInfo GetLoginTicket(string hid)
        {
            ResultInfo res = T_HospitalService.GetLoginTicket(hid);
            return res;
        }

        [HttpPost, Route("Login")]
        public ResultInfo Login()
        {
            var req = HttpContext.Current.Request;
            string hid = req.Form["hid"];
            string username = req.Form["username"];
            string pwd = req.Form["pwd"];
            string ticket = req.Form["ticket"];
            string code = req.Form["code"];

            ResultInfo res = T_HospitalService.Login(hid,username,pwd,ticket,code);
            return res;
        }

        [HttpPost, Route("EditLoginInfo")]
        public ResultInfo EditLoginInfo()
        {
            var req = HttpContext.Current.Request;
            string hid = req.Form["hid"];
            string username = req.Form["username"];
            string pwd = req.Form["pwd"];
            string repeat_pwd = req.Form["repeat_pwd"];

            ResultInfo res = T_HospitalService.EditLoginInfo(hid,username,pwd,repeat_pwd);
            return res;
        }
    }
}
